package top.oneit.jdownload.test;

import com.sun.javafx.application.PlatformImpl;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.input.KeyCombination;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.GridPane;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.util.Pair;

import java.util.Optional;

/**
 * @author lingkang
 * Created by 2021/12/6
 */
public class MyDialog extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception {
        Button button = new Button("open");
        button.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
                Stage stage=new Stage();
                stage.setTitle("message");
                stage.initModality(Modality.APPLICATION_MODAL);
                stage.initStyle(StageStyle.UTILITY);// 配合公共组件样式效果更好
                stage.setScene(new Scene(new Button("stage")));

                stage.setWidth(400);
                stage.setHeight(200);
                stage.show();
            }
        });

        primaryStage.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH);
        AnchorPane anchorPane = new AnchorPane(button);
        primaryStage.setScene(new Scene(anchorPane));
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
